import { EObjCmpType } from "../../debug_inject/common/EObjCmpType";
import { BaseCmpData } from "../../debug_inject/common/BaseCmpData";

export class BaseViewCmp {

    public type: EObjCmpType;
    public ui: fgui.GObject;
    public objId: number;

    constructor(type: EObjCmpType, objId: number) {
        this.type = type;
        this.objId = objId;
    }

    public Refresh(data: BaseCmpData, objId: number) {
        this.objId = objId;
        if (data.type != this.type) {
            console.error("错误的数据类型", this.type, data);
            return;
        }
        this._OnRefresh(data);
    }

    protected _OnRefresh(data: BaseCmpData) {

    }

    public Dispose() {
        this._OnDispose();
        if (this.ui && !this.ui.isDisposed) {
            this.ui.dispose();
            this.ui = null;
        }
    }

    protected _OnDispose() {

    }

}